package com.gzx.plugin.tjzy.modular.liaison.mapper;

import com.gzx.plugin.tjzy.modular.liaison.entity.GzxDebtorLiaison;
import com.gzx.plugin.tjzy.modular.liaison.entity.vo.GzxDebtorLiaisonVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import vip.xiaonuo.common.mapper.BaseMapperPlus;

import java.util.List;

/**
 * 欠款人关系人的通讯录Mapper接口
 *
 * @author LionLi
 * @date 2024-09-13
 */
public interface GzxDebtorLiaisonMapper extends BaseMapperPlus<GzxDebtorLiaison, GzxDebtorLiaisonVo> {

    /**
     * 批量新增欠款联系人
     *
     * @param sql
     */
    @Insert("<script>" +
            "insert ignore into gzx_debtor_liaison" +
            "(project_code, debtor_card_id, call_recipient, relationship, liaison_name,liaison_phone," +
            "phone_source, remark, tenant_id, create_user, create_time) " +
            "values ${sql}" +
            "</script>")
    void insertBatchBySql(String sql);

    /**
     * 批量新增三方联系人
     *
     * @param batchSql
     */
    @Insert("<script>" +
            "INSERT ignore INTO gzx_debtor_liaison (" +
            "project_code,debtor_card_id,relationship,liaison_name,liaison_phone,work_address,phone_source," +
            "tenant_id,create_user,create_time) " +
            "VALUES ${batchSql}" +
            "</script>")
    void insertBatch(String batchSql);

    /**
     * 查询欠款人员联系人
     */
    @Select("<script>" +
            "SELECT * " +
            "FROM gzx_debtor_relation_phone gdrp " +
            "WHERE debtor_card_id in " +
            "<foreach collection=\"list\" item=\"item\" separator=\",\" open=\"(\" close=\")\"> " +
            "#{item} " +
            "</foreach>" +
            "and liaison_phone != '9WPapKfBgFvI4ceskTx09w==' " +
            "</script>")
    List<GzxDebtorLiaison> selectCaseContacts(@Param("list") List<String> debtorCardIds);
}
